<template>
	<view class="main">
		<view class="main-top">
			<image :src="getStaticFilePath('/main/minebanner.png')" mode=""></image>
			<view class="public-nav">
				<view class="public-nav-fixed" style="background-color: rgba(255,255,255,0);color: #333;">
					<view class="public-nav-top">
						<view class="public-nav-top-status-bar" :style="{ height: systemInfo.statusBarHeight + 'px' }">
						</view>
						<view class="public-nav-top-navbar-inner"
							:style="{ height: navHeight + 'px', lineHeight: navHeight + 'px' }">
							<text class="iconfont iconarrow_left-copy" @click="returnclick"></text>
							<view>我的账户</view>
						</view>
					</view>
				</view>
			</view>
			<view class="main-top-content">
				<view class="public-nav-placeholder"
					:style="{ height: Number(navHeight) + Number(systemInfo.statusBarHeight) + 'px' }">
				</view>
				<view class="query-favoured-policy"
					:style="{ top: Number(navHeight) + Number(systemInfo.statusBarHeight) + 'px' }" @click="youhui">查看优惠政策
				</view>
				<view class="main-top-total">
					<view>账户总额</view>
					<view v-if="AuthorizationOBJ.ORMTB417CA06 == 0">***</view>
					<view style="font-weight: 600;" v-else>{{ accountList.ORMTB410CA03 }}</view>
				</view>
				<view class="main-top-money">
					<view>
						<view @click="yukou">预扣金额 <text class="iconfont iconarrow_right"></text></view>
						<view v-if="AuthorizationOBJ.ORMTB417CA06 == 0">***</view>
						<view style="font-weight: 600;" v-else>{{ accountList.ORMTB410CA04 }}</view>
					</view>
					<view>
						<view>可用金额</view>
						<view v-if="AuthorizationOBJ.ORMTB417CA06 == 0">***</view>
						<view style="font-weight: 600;" v-else>{{ accountList.ORMTB410CA05 }}</view>
					</view>
				</view>
				<view class="main-top-tixian" v-if="ErpUserTypeText == 'HF' && userinfo.sign == 'CUS-2'">
					<text @click="onlineRecharge">线上充值</text>
					<text @click="TXClick">提现</text>
				</view>
			</view>
		</view>
		<view class="main-content-acc">
			<view class="main-content-li" @click="ChildAccount">
				<text class="iconfont iconzhangdan1"></text>
				<view class="main-content-li-right">
					<text>账单明细</text>
					<text class="iconfont iconarrow_right"></text>
				</view>
			</view>
			<view class="main-content-li" v-if="ErpUserTypeText == 'HF' && userinfo.sign == 'CUS-2'"
				@click="WithdrawalTypeClick">
				<text class="iconfont iconzhangdan1"></text>
				<view class="main-content-li-right">
					<text>支付管理</text>
					<text class="iconfont iconarrow_right"></text>
				</view>
			</view>
			<view class="main-content-li" v-if="ErpUserTypeText == 'HF' && userinfo.sign == 'CUS-2'"
				@click="WithdrawalRecord">
				<text class="iconfont iconzhangdan1"></text>
				<view class="main-content-li-right">
					<text>提现记录</text>
					<text class="iconfont iconarrow_right"></text>
				</view>
			</view>
			<view class="main-content-li" v-if="ErpUserTypeText == 'HF' && userinfo.sign == 'CUS-2'"
				@click="onlinePaymentRecord">
				<text class="iconfont iconzhangdan1"></text>
				<view class="main-content-li-right">
					<text>线上支付记录</text>
					<text class="iconfont iconarrow_right"></text>
				</view>
			</view>
			<view class="main-content-li" v-if="ErpUserTypeText == 'HF' && userinfo.sign == 'CUS-2'" @click="jumpPage"
				data-url="/pages/wallet/bank-list/bank-list">
				<!-- <view class="main-content-li" v-if="ErpUserTypeText=='HF'&&userinfo.sign == 'CUS-2'" @click="jumpPage"
				data-url="/pages/wallet/bank-add/bank-add"> -->
				<text class="iconfont iconzhangdan1"></text>
				<view class="main-content-li-right">
					<text>我的银行卡</text>
					<text class="iconfont iconarrow_right"></text>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>
<script>
export default {
	data() {
		return {
			background: {
				backgroundColor: '#00a1f1',
			},
			userinfo: JSON.parse(uni.getStorageSync('userinfo')),
			accountList: [],
			AuthorizationOBJ: '',
			ErpUserTypeText: '',
			systemInfo: '',
			navHeight: '',
		}
	},
	onShow() {
		this.systemInfo = uni.getSystemInfoSync()
		this.navHeight = this.systemInfo.platform == 'ios' ? 44 : 48;
		this.ErpUserTypeText = this.ErpUserType
		this.getData()
		if (this.userinfo.sign == 'CUS-3') {
			this.queryAuthorization()
		}
	},
	methods: {
		returnclick() {
			uni.reLaunch({
				url: '/pages/tabbar/main/index'
			})
		},
		TXClick() {
			uni.navigateTo({
				url: '/pages/myWithdrawal/index'
			})
		},
		queryAuthorization() { //查询子账户权限
			uni.showLoading({
				title: '加载中...',
				mask: true
			});
			uni.request({
				url: this.baseUrl + '/orm/ormtb417/selectAccess/' + this.userinfo.ORMTB417ID,
				method: 'GET',
				success: (res) => {
					console.log(res);
					uni.hideLoading();
					if (res.data.code == 200) {
						this.AuthorizationOBJ = res.data.data
					} else {
						this.$refs.uToast.show({
							title: res.data.message,
							type: 'default',
							icon: false
						})
					}
				},
				fail: (res) => {
					uni.hideLoading();
					this.$refs.uToast.show({
						title: res.errMsg,
						type: 'default',
						icon: false
					})
				}
			});
		},
		getData() {
			uni.showLoading({
				title: '请求中...',
				mask: true
			});
			uni.request({
				url: this.baseUrl + '/orm/ormtb410/select410ListById',
				method: 'POST',
				dataType: 'json',
				data: {
					ORMTB400ID: this.userinfo.ORMTB400ID, //一级客户ID
					ORMTB410ID: this.userinfo.ORMTB410ID, //二级客户ID
				},
				success: (res) => {
					console.log(res);
					if (res.data.code == 200) {
						this.accountList = res.data.data[0];
					} else {
						this.accountList = [];
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
					uni.hideLoading();
				},
				fail: (res) => {
					uni.hideLoading();
					uni.showToast({
						title: res.data.message,
						duration: 5000,
						icon: 'none',
					});
				}
			});
		},
		ChildAccount() {
			if (this.AuthorizationOBJ.ORMTB417CA06 && this.AuthorizationOBJ.ORMTB417CA06 == 0) {
				uni.showToast({
					title: '您没有操作权限',
					duration: 5000,
					icon: 'none',
				});
				return
			}
			uni.navigateTo({
				url: '../accountbalance/index'
			})
		},
		youhui() {
			if (this.AuthorizationOBJ.ORMTB417CA06 && this.AuthorizationOBJ.ORMTB417CA06 == 0) {
				uni.showToast({
					title: '您没有操作权限',
					duration: 5000,
					icon: 'none',
				});
				return
			}
			uni.navigateTo({
				url: '../accountFavouredPolicy/index'
			})
		},
		yukou() {
			if (this.AuthorizationOBJ.ORMTB417CA06 && this.AuthorizationOBJ.ORMTB417CA06 == 0) {
				uni.showToast({
					title: '您没有操作权限',
					duration: 5000,
					icon: 'none',
				});
				return
			}
			uni.navigateTo({
				url: '../accountwithholding/index'
			})
		},
		onlineRecharge() {
			// uni.showToast({
			// 	title: '功能暂停使用！！！',
			// 	duration: 5000,
			// 	icon: 'none',
			// });
			uni.navigateTo({
				url: '../accountOnlineRecharge/index'
			})
		},
		WithdrawalTypeClick() {
			uni.navigateTo({
				url: '/pages/myWithdrawalType/index'
			})
		},
		WithdrawalRecord() {
			uni.navigateTo({
				url: '/pages/WithdrawalRecord/index'
			})
		},
		onlinePaymentRecord() {
			uni.navigateTo({
				url: '/pages/onlinePaymentRecord/index'
			})
		},
		jumpPage(e) {
			console.log(e)
			let { url } = e.currentTarget.dataset
			uni.navigateTo({ url })
		}
	}
}
</script>

<style scoped>
.main {
	min-height: 100vh;
	width: 100vw;
	background-color: #efeff4;
}

.main-top {
	position: relative;
	height: 35vh;
}

.main-top>image {
	position: absolute;
	width: 100%;
	height: 100%;
	z-index: 1;
}

.main-top-content {
	width: 100%;
	height: 35vh;
	position: relative;
	font-size: 36rpx;
	/* top: 75%; */
	/* transform: translateY(-60%); */
	z-index: 2;
	/* padding: 0 30rpx; */
	color: #fff;
	text-align: center;
}

.main-top-money .iconarrow_right {
	color: #fff !important;
}

.query-favoured-policy {
	position: absolute;
	right: 0;
	background: #fff;
	color: #FCAA1A !important;
	border-radius: 20rpx;
	padding: 5rpx 10rpx;
}

.main-top-total {
	width: 150rpx;
	margin: 10rpx auto;
	font-size: 36rpx;
}

.main-top-money {
	display: flex;
	justify-content: space-around;
}

.main-content-acc {
	background-color: #fff;
	border-radius: 10rpx;
	margin: 30rpx 0;
	/* padding: 15rpx 0; */
}

.main-content-li {
	display: flex;
	height: 80rpx;
	line-height: 80rpx;
	padding-right: 20rpx;
	font-size: 32rpx;
	color: #333;
}

.main-content-li+.main-content-li .main-content-li-right {
	border-top: 2rpx solid #e3e3e3;
}

.main-content-li .iconfont {
	width: 100rpx;
	text-align: center;
	font-size: 36rpx;
}

.main-content-li-right {
	flex: 1;
	display: flex;
	justify-content: space-between;
	padding-left: 10rpx;
}

.main-content-li-right .iconarrow_right {
	text-align: right;
}

.iconarrow_right {
	font-size: 32rpx;
	color: #999;
}

.iconzhanghu {
	font-size: 28rpx;
}

.iconzhanghaoguanli {
	color: rgb(0, 161, 241);
}

.iconzhangdan1 {
	color: rgb(0, 202, 242);
}

.iconwuliaoguanli {
	color: rgb(0, 161, 241);
}

.iconshezhi {
	color: rgb(230, 192, 0);
}

.iconerweimaxiazai {
	color: rgb(255, 99, 99);
}

.main-top-tixian {
	position: absolute;
	bottom: 0;
	width: 100%;
}

.main-top-tixian text {
	background: rgba(255, 255, 255, .5);
	width: 50%;
	height: 70rpx;
	line-height: 70rpx;
	display: inline-block;
	position: relative;
	bottom: 0;
	overflow: hidden;
	vertical-align: bottom;
}

.main-top-tixian text:first-child {
	left: -1%;
}

.main-top-tixian text:last-child {
	right: 0%;
}

/* .main-top-tixian text:nth-child(2){
		width: 1%;
	} */
</style>
